package com.bawei.mall.user.factory;

import com.bawei.common.core.domain.R;
import com.bawei.common.core.utils.StringUtils;
import com.bawei.mall.user.domain.CusUser;
import com.bawei.mall.user.remote.RemoteUserInfo;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author：HaoYunde
 * @Package：com.bawei.mall.user.factory
 * @Project：mall_cloud
 * @name：RemoteUserInfoFallbackFactory
 * @Date：2024/6/27 17:05
 */
@Component
public class RemoteUserInfoFallbackFactory implements FallbackFactory<RemoteUserInfo> {


    @Override
    public RemoteUserInfo create(Throwable cause) {
        return new RemoteUserInfo() {
            @Override
            public R<CusUser> findCusUserByName(String username) {
                return R.fail(StringUtils.format("远程调用失败，错误信息:[{}]",cause.getMessage()));
            }
        };
    }
}
